﻿using RepositoryDefinition;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RepositoryImplementation
{
    public class AnswerRepository:IAnswerRepository
    {
        public List<ForumDomainModels.Answer> GetAnswersByPost(ForumDomainModels.Post post)
        {
            try
            {
                ForumDAL.AnswerDAL answerContext = new ForumDAL.AnswerDAL();
                List<ForumDomainModels.Answer> answers = answerContext.GetAnswersByPost(post);
                return answers;
            }
            catch (ForumDAL.CustomExceptions.NoRowsRetrieved e)
            {
                return null;
            }
        }

        public void InsertAnswer(ForumDomainModels.Answer answer)
        {
            ForumDAL.AnswerDAL answerContext = new ForumDAL.AnswerDAL();
            answerContext.InsertAnswer(answer);
        }
    }
}
